package com.eselect.mq.consumer;

import lombok.extern.slf4j.Slf4j;
import org.springframework.amqp.core.ExchangeTypes;
import org.springframework.amqp.core.Message;
import org.springframework.amqp.rabbit.annotation.*;
import org.springframework.stereotype.Component;

@Component
@Slf4j
public class ErrorConsumer {

    /**
     * 异常交换器处理机制
     */
    @RabbitListeners({
            @RabbitListener(bindings = @QueueBinding(
                    value = @Queue(value = "error.exchange.queue1", durable = "true", arguments = @Argument(name = "x-queue-mode", value = "lazy")),
                    exchange = @Exchange(value = "error.exchange", type = ExchangeTypes.DIRECT),
                    key = {"error.routing.key"}
            ))
    })
    public void ErrorDirectQueueConsumer1(Message message){
        String msg = new String(message.getBody());
        log.error("ErrorDirectQueueConsumer1 异常队列 接收到消息：{}",  msg);
    }
}
